package com.itheima.reggie.Controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.itheima.reggie.Service.OrdersService;
import com.itheima.reggie.bean.Orders;

import com.itheima.reggie.common.PageParam;
import com.itheima.reggie.common.R;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author LiuKeLin
 * @title: OrdersController
 * @projectName itcaset_reggie
 * @description: TODO
 * @date 2022/1/510:21
 */
@RestController
@RequestMapping("/order")
public class OrdersController {


    @Autowired
    private OrdersService ordersService;

    /*
     * 更新状态
     */
    @PutMapping
    public R update(@RequestBody Orders orders){
        int rows = ordersService.update(orders);
        if (rows >0){
            return R.success("状态更新成功！");
        }else {
            return R.error("状态更新失败！");
        }
    }

    /*
     * 分页查询
     */
    @GetMapping("/page")
    public R page(PageParam pageParam){
        //System.out.println("pageParam = " + pageParam);
        IPage<Orders> page =ordersService.page(pageParam);
        return R.success(page);
    }
}
